﻿Imports System.Data
Imports FuncClasses

Public Class UnknownUnit
    Private _xml As IDatabase
    Public Sub New(ByVal Unknown As String, xml As IDatabase)

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        Dim dt As New DataTable("Units")
        dt.Columns.Add("Name")
        For Each u As Unit In xml.ListOfUnits
            dt.Rows.Add(u.Name)
        Next
        ComboBox1.DataContext = dt
        Me.Resources.MergedDictionaries.Add(Dictionaries.GetDialogeLocalization)
        TextBlock1.Text = FindResource("Text1") + Unknown + FindResource("Text2")
        _xml = xml
    End Sub

    Public ReadOnly Property Unit As Unit
        Get
            Return Unit.GetByName(ComboBox1.Text, _xml)
        End Get
    End Property

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Me.DialogResult = False
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click
        Me.DialogResult = True
        Me.Close()
    End Sub
End Class
